import java.util.LinkedList;
import java.util.*;

/*
 * @Author: qianmingtian
 * @Date: 2020-06-19 10:29:50
 * @LastEditors: qianmingtian
 * @LastEditTime: 2020-06-19 11:53:56
 * @FilePath: \qianmingtian.github.io\code\java\LinkedListTest.java
 */
public class LinkedListTest {
    public static void main(String[] args) {
        List<String> a = new LinkedList<String>();
        a.add("1");
        a.add("2");
        a.add("3");

        List<String> b = new LinkedList<String>();
        b.add("b1");
        b.add("b2");
        b.add("b3");

        ListIterator<String> aItor = a.listIterator();
        Iterator<String> bItor = b.iterator();

        while (bItor.hasNext()) {
            if (aItor.hasNext()) {
                aItor.next();
            }
            aItor.add(bItor.next()); 
        }

        System.out.println(a);
        // [1, b1, 2, b2, 3, b3]

        bItor = b.listIterator();
        while (bItor.hasNext()) {
            bItor.next();
            if (bItor.hasNext()) {
                bItor.next();
                bItor.remove();
            }
        }
        System.out.println(b);
        // [b1, b3]
        a.removeAll(b);
        
        System.out.println(a);
        // [1, 2, b2, 3]
    

    }
}